// var dbpath = './db.json'
// var fs = require('fs')

var mongoose = require('mongoose')
var Schema = mongoose.Schema
mongoose.connect('mongodb://localhost/artoria')

mongoose.set('useFindAndModify', false)
var stuSchema = new Schema({
  name: {
    type: String,
    required: true
  },
  gender: {
    type: String,
    enum: [0, 1],
    required: true
  },
  age: {
    type: Number,
    required: true
  },
  hobbies: {
    type: String
  }
})

var Student = mongoose.model('Student', stuSchema)

// Student.find(function (err, ret) {
//   if (err) {
//     console.log('查询失败')
//   } else {
//     console.log(ret)
//   }
// })

module.exports = mongoose.model('Student', stuSchema)
